<template>
	<view class="more">
		<view class="search-view">
			<u-search placeholder="搜索" :disabled="true" :show-action="false" @click="clickSearch" height="37">
			</u-search>
		</view>
		<view class="swiper-view">
			<u-swiper :list="swiperImgArray" :autoplay="true" radius="0" height="232rpx">
				<view slot="indicator" class="indicator">
					<view class="indicator__dot" v-for="(item, index) in swiperImgArray" :key="index"
						:class="[index === current && 'indicator__dot--active']">
					</view>
				</view>
			</u-swiper>
		</view>

		<view class="goods-list">
			<waterfallsFlow imageSrcKey="seriesOne" :list="wishList">
				<template v-slot:default="item">
					<GoodsItem :isNoImg="true" :isClick="true" :pp="item.pp" :goodsItem="item">
					</GoodsItem>
				</template>
			 </waterfallsFlow >
		</view>
		
		<view class="hint" v-if="isShow">
			
			{{$t("wishGoods.blank")}}
		</view>
	</view>
</template>

<script>
	import search from '@/components/search.vue'
	import moreItem from '@/components/moreItem.vue'
	import {
		getSwiper,
		wishMatching
	} from "@/common/api.js"
	import waterfallsFlow from "@/components/maramlee-waterfalls-flow/maramlee-waterfalls-flow.vue";

	export default {
		components: {
			search,
			moreItem,
			waterfallsFlow
		},
		data() {
			return {
				swiperImgArray: [],
				current: 0,
				wishList: [],
				id: null,
				isShow: false
			}
		},
		methods: {
			clickSearch() {
				uni.navigateTo({
					url: '/pages/search/search'
				})
			},
			//轮播图获取
			async getSwiperImg() {
				const res = await getSwiper({
					parentId: 1
				});
				if (res.code == 200) {
					res.rows.forEach(e => {
						this.swiperImgArray.push(e.url)
					})
				}
			},
			async initData() {
				console.log(this.id);
				const res = await wishMatching(this.id);
				console.log(res);
				if(res.code == 200) {
					if(res.rows.length <= 0) {
						this.isShow = true;
						return
					}
					this.wishList = res.rows.map((item, index) => {
						let temp = {...item.commodity};
						temp["order"] = item.order;
						temp["pp"] = item.pp;
						// res.rows[index] = temp;
						return temp
					});
					console.log(this.wishList);
				} else {
					this.isShow = true;
				}
			}
		},
		onReady() {
			uni.setNavigationBarTitle({
				title: this.$t("categoryShow.title")
			});
		},
		onLoad(option) {
			this.getSwiperImg();
			this.id = option.id;
			this.initData();
		}
	}
</script>

<style scoped lang="scss">
	.swiper-view {
		margin: 14rpx 0px;
		margin-top: 102rpx;
	}
	
	.hint {
		text-align: center;
		font-size: 50rpx;
		color: #FAAD67;
		font-weight: bold;
		margin-top: 100rpx;
	}

	.item {
		display: flex;
	}

	.search-view {
		padding: 14rpx 22rpx;
		position: fixed;
		/* #ifdef APP */
		top: 0;
		/* #endif */
		
		/* #ifdef H5 */
		top: 86rpx;
		/* #endif */
		left: 0;
		right: 0;
		z-index: 1;
		background-color: #fff;
	}

	.screen-bar {
		width: 100%;
		border-radius: 20rpx 20rpx 0rpx 0rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 16rpx 0rpx #0000000C;
		height: 88rpx;
		display: flex;
		align-items: center;
		color: #717184;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 26rpx;

		.sreen-left {
			width: 82%;
			display: flex;
			align-items: center;
			justify-content: center;
			border-right: 5rpx solid #858585;

			.comp {
				margin-right: 155rpx;
			}

			.sales {}
		}

		.filter {
			width: 18%;
			margin-left: 30rpx;
		}
	}

	.active {
		color: #FAAD67;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 26rpx;
	}

	.screen {
		width: 100%;
		background: #FBFBFB;
		box-shadow: 0px -1px 8px rgba(0, 0, 0, 0.1);
		border-radius: 10px;
	}

	.more {
		padding: 0rpx 24rpx;
		width: 100%;
		box-sizing: border-box;
	}

	.indicator {
		@include flex(row);
		justify-content: center;

		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: #ffffff;
			}
		}
	}

	.commodity-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 0 30rpx;
	}

	.goods-list {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 0rpx 20rpx;
		padding-bottom: 20rpx;
		box-sizing: border-box;
	}

	.footer-goods {
		border-radius: 20rpx;
		background: #FBFBFB;
		box-shadow: 0rpx 0rpx 16rpx 0rpx #00000019;
	}

	.side {
		width: 600rpx;
		// height: 100%;
		overflow-y: scroll;
		padding-bottom: 100rpx;

		.filter-pla {
			height: 200rpx;
			width: 0;
		}

		.side-footer {
			position: fixed;
			bottom: 0;
			width: 600rpx;
			height: 88rpx;
			display: flex;
			align-items: center;

			.reset-btn {
				width: 50%;
				height: 100%;
				background: #FFFFFF;
				box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.25);
				font-family: 'PingFang SC';
				font-style: normal;
				font-weight: 700;
				font-size: 30rpx;
				color: #858585;
				text-align: center;
				line-height: 88rpx;
			}

			.confirm-btn {
				width: 50%;
				height: 100%;
				font-family: 'PingFang SC';
				font-style: normal;
				font-weight: 700;
				font-size: 30rpx;
				color: #fff;
				text-align: center;
				line-height: 88rpx;
				background-color: #000000;
			}
		}

		.filter-item {
			padding-left: 40rpx;
			margin-top: 40rpx;

			.title-item {
				font-family: 'PingFang SC';
				font-style: normal;
				font-weight: 700;
				font-size: 30rpx;
			}

			.select-list {
				display: flex;
				align-items: center;
				flex-wrap: wrap;

				.select-item {
					margin: 0 15rpx;
					margin-top: 20rpx;
					// width: 150rpx;
					padding: 0 40rpx;
					height: 60rpx;
					font-family: 'PingFang SC';
					font-style: normal;
					font-weight: 700;
					font-size: 20rpx;
					color: #858585;
					text-align: center;
					line-height: 60rpx;
					background: #F6F6F6;
					border-radius: 40rpx;
				}
			}
		}
	}

	.select-active {
		background: #FAAD67 !important;
		color: #fff !important;
	}

	.screen-bar {
		width: 100%;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 0 0;
		height: 88rpx;
		display: flex;
		align-items: center;
		color: #717184;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 26rpx;

		.sreen-left {
			width: 82%;
			display: flex;
			align-items: center;
			justify-content: center;
			border-right: 5rpx solid #858585;

			.all {
				margin-right: 88rpx;
			}

			.sold {
				margin-right: 88rpx;
			}
		}

		.filter {
			width: 18%;
			margin-left: 30rpx;
			display: flex;
			align-items: center;

			.screen-img {
				width: 30rpx;
				height: 30rpx;
			}
		}
	}

	.active {
		color: #FAAD67;
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 26rpx;
	}
</style>
